/**
 * store状态管理
 */

import { ThunkAction, configureStore } from "@reduxjs/toolkit";
import { Action, combineReducers } from "redux";
import base from "./modules/base";
import demo from "./modules/demo";

const store = configureStore({
  reducer: combineReducers({
    base: base.reducer,
    demo: demo.reducer,
  }),
  // 使用回调函数来自定义中间件
  // middleware: (getDefaultMiddleware) =>
  //   getDefaultMiddleware()
  //     .configure({ serializableCheck: false }) // 你可以禁用或配置默认中间件
  //     .concat(logger), // 你可以添加更多中间件
});
export default store;

export type SliceNames = keyof typeof sliceMap;
export const sliceMap = {
  base,
  demo,
};

export type RootDispatch = typeof store.dispatch;
export type RootState = ReturnType<typeof store.getState>;
export type RootThunk<ReturnType = void> = ThunkAction<
  ReturnType,
  RootState,
  unknown,
  Action<string>
>;
